home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patch 5.1.1.2 / SGI IRIX Patch 5.1.1.2.iso / 5.1.1.1 / CDrelnotes < prev   
Text File  |  1993-11-05  |  3KB  |  134 lines

  1. #! /bin/sh
  2. #Tag 0x00000600
  3.  
  4. # 'relnotes' - View on-line release notes; this version for online
  5. # (on CD-ROM) release notes
  6.  
  7. SRCDIR=`dirname $0`/relnotes/
  8.  
  9. # if term not set, or no terminfo dirs, assume we are on the
  10. # textport in the miniroot
  11. if [ ! -n "$TERM" -o \( ! -d /usr/lib/terminfo -a ! -d "$TERMINFO" \) ]
  12. then
  13.     TERM=dumb LINES=40 COLUMNS=80
  14.     export TERM LINES COLUMNS
  15. fi
  16.  
  17. Usage="\n
  18.     'relnotes -h' -- print this message\n
  19.     'relnotes' -- list products that have on-line release notes \n
  20. \t\t\tcurrently installed\n
  21.     'relnotes <product>' -- show table of contents for a product's \n
  22. \t\t\ton-line release notes\n
  23.     'relnotes <product> <chapter> ... ' -- display specific chapters of \n
  24. \t\t\t\ta product's on-line release notes\n
  25.     'relnotes -t <product> <chapter> ... ' -- print specific chapters of \n
  26. \t\t\t\ta product's on-line release notes\n"
  27.  
  28. if [ "$1" = "-h" ] # give help and exit
  29. then
  30.     echo $Usage
  31.     exit
  32. fi
  33.  
  34. list_relnotes=/tmp/relnoteslist$$
  35. product=/tmp/relnotesproduct$$
  36. cleanup="rm -f $list_relnotes $product"
  37. trap "$cleanup" 1 2 3 15
  38.  
  39. # Create a list of products which have release notes installed.
  40. (cd $SRCDIR; find . -follow -type f -name "ch*.z" -print |  \
  41.     sed -e 's%./%%' -e "s%/ch.*\.z%%" | sort -u ) > $list_relnotes
  42. if [ ! -s $list_relnotes ]
  43. then
  44.     echo "Sorry, but no products have release notes installed\n"
  45.     rm -f $list_relnotes
  46.     exit
  47. fi
  48.  
  49. if [ $# -eq 0 ]    # no args - show installed relnotes
  50. then
  51.     echo "The following products have release notes installed:\n"
  52.     cat $list_relnotes
  53.     echo "\nUse \"$0 productname\" to see the chapter list for a product"
  54.     $cleanup
  55.     exit
  56. fi
  57.  
  58. validproduct=no
  59. tflag=
  60. while [ $# -gt 0 ] # As long as we have arguments ....
  61. do
  62.     # Recognize old-style args, but don't support them.
  63.     if [ "$1" = "-p" ]
  64.     then
  65.       echo "The -p and -c options are no longer needed."
  66.       echo $Usage
  67.       $cleanup 
  68.       exit 1
  69.     fi
  70.  
  71.     # Support for printing chapters.
  72.     if [ "$1" = "-t" ]
  73.     then
  74.       tflag=$1
  75.       shift 
  76.       continue
  77.     fi
  78.     
  79.     # Invalid option?
  80.     case "$1" {
  81.     -*)
  82.       echo "$1 is an invalid option."
  83.       echo $Usage
  84.       $cleanup
  85.       exit 1
  86.       ;;
  87.     }
  88.  
  89.     if [ "$validproduct" = "no" ]
  90.     then
  91.       echo $1 > $product
  92.       match=`comm -12 $list_relnotes $product  | wc -l`
  93.       if [ $match -eq 1 ];
  94.       then
  95.          validproduct=$1    
  96.          shift
  97.          if [ $# -gt 0 ];
  98.          then
  99.             continue
  100.          fi
  101.          if [ -f $SRCDIR$validproduct/TC ];
  102.          then
  103.             echo "The chapters for the \"$validproduct\" product's release notes are:\n"
  104.             cat $SRCDIR$validproduct/TC 
  105.          else
  106.             echo "The \"$validproduct\" product's release notes are installed, "
  107.             echo "but its table of contents file is missing.\n"
  108.             echo "The chapters that are installed are:\n"
  109.             cd $SRCDIR${validproduct}; /bin/ls ch*.z | sed -e "/ch\(.*\)\.z/s//\1/"
  110.          fi
  111.          echo "\nUse \"$0 productname chapter\" to view a chapter"
  112.       else  # Not an installed product
  113.          echo "Sorry, but there are no installed release notes for the \"$1\" product.\n"
  114.          $cleanup ; exit 1
  115.       fi
  116.     else # Have a valid product.
  117.       cd $SRCDIR$validproduct
  118.       # Let 'man' report on chapters it can't find.
  119.       man $tflag -d ch${1}.z
  120.       shift
  121.       if [ $# -gt 0 ];
  122.       then
  123.         echo "Next chapter ('q' to quit):\c"
  124.         read ans
  125.         if [ "$ans" = "q" ];
  126.         then
  127.             $cleanup
  128.             exit
  129.         fi
  130.       fi
  131.     fi
  132. done
  133. $cleanup
  134.